<?php
// 含入系統（資料庫）設定檔
require('config.inc.php');
require('db.php');

// 連結資料庫伺服器
db_connect();

// 選擇資料庫
db_select();

session_start(); 
if($_SESSION['ID']!= null){
	$ID=$_SESSION['ID'];
	$UserNo=$_SESSION['UserNo']; 

$sql = '';
$sql .= 'SELECT * FROM Authentication WHERE UserNo=\'' . $UserNo . '\'';
$result = mysql_query($sql);

while ($row = mysql_fetch_assoc($result)) {
    $Password = $row['Password'];
    $Name = $row['Name'];
    $Sex = $row['Sex'];
    $Email = $row['Email'];
}

// 資料庫連結斷線
db_close();

?>
<title>修改會員資料</title>

<p>您的會員資料是</p>
<form id="frmUpdate" name="frmUpdate" method="post" action="user_final.php">
  <p>帳號：<?php echo $ID;?></p>
  <p>密碼：
    <input name="txtPassword" type="text" id="txtPassword" value="<?php echo $Password;?>" />
  </p>
  <p>姓名：
    <input type="text" name="txtName" id="txtName" value="<?php echo $Name;?>"/>
  </p>
  <p>性別：
<?php
 	if($Sex=="M"){
    	echo "<input name=\"sex\" type=\"radio\" id=\"M\" value=\"M\" checked=\"checked\" />";
    	echo "<label for=\"M\">男</label>";
    	echo "<input type=\"radio\" name=\"sex\" id=\"F\" value=\"F\" />";
    	echo "<label for=\"F\">女</label>";
	} else {
    	echo "<input name=\"sex\" type=\"radio\" id=\"M\" value=\"M\" />";
    	echo "<label for=\"M\">男</label>";
    	echo "<input type=\"radio\" name=\"sex\" id=\"F\" value=\"F\" checked=\"checked\"/>";
    	echo "<label for=\"F\">女</label>";
	}
?>
  </p>
  <p>E-mail：  
    <input type="text" name="txtEmail" id="txtEmail" value="<?php echo $Email;?>"/>
  </p>
  <p>&nbsp;</p>
  <p>修改完成後請按 
    <input type="submit" name="btnSubmit" id="btnSubmit" value="送出" />
  </p>
</form>
<?
}else{
   header("Location:"."login.html");
}
?>
<p>&nbsp; </p>